﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using sexhealth.console.service.post;
using sexhealth.console.service.post.vo;

public partial class admin_UC06_0601linkmaintain : System.Web.UI.Page
{
    PostService postService = new PostService();
    int channelId = 20;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ShowContent();
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        IList<PostVO> postList = postService.GetPostList(channelId);
       if (postList.Count > 0)
       {
           postList[0].HtmlContent = ckbContent.value;
           postList[0].Title = "好站連結";
           postService.UpdatePost(postList[0]);

       }
       else 
       {
           PostVO post = new PostVO();
           post.HtmlContent = ckbContent.value;
           post.Title = "好站連結";
           post.BelongToChannelId = channelId;
           postService.InsertPost(post);
      
       }
       ShowContent();
    }
    private void ShowContent()
    {
        IList<PostVO> postList = postService.GetPostList(channelId);
        if (postList.Count > 0)
        {
            ckbContent.value = postList[0].HtmlContent;
        }
        
    }
 
}
